package secondPart.polymorphism;

public class initial2 {
    public static void main(String[] args) {
        Dog dog = new Dog();
        Animal animal = dog; // 自动类型提升，向上类型转换
        if (animal instanceof Dog) {
            Dog dog2 = (Dog) animal; // 向下类型转换，强制类型转换
            System.out.println("9 true");
        } else {
            System.out.println("11 false");
        }

        if (animal instanceof Cat) {
            Cat cat = (Cat) animal;
        } else {
            System.out.println("17 无法进行类型转换");
        }
    }
}
